<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/2/23 0023
 * Time: 14:52
 */

namespace app\common\validate;

use think\Validate;

class User extends Validate
{
    protected $rule = [
        'username|用户名' => 'require|unique:user|length:4,10',
        'oldpass|原密码' => 'require',
        'password|密码' => 'require|length:4,10',
        'conpass|确认密码' => 'require|confirm:password',
        'verify|验证码' => 'require|captcha'
    ];

    protected $scene = [
        'add' => ['username', 'password', 'conpass'],
        'edit' => ['oldpass', 'password'],
        'register' => ['username', 'password', 'conpass', 'verify']
    ];
    public function sceneLogin()
    {
        return $this->only(['username', 'password', 'verify'])
            ->remove('username', ['unique']);
    }
}